<?php App::import('Sanitize'); ?>
<div class="welcome">
	<div class="tabs">
		<?php echo $html->link('Updates', "", array('class'=>'selected')); ?>
		<span>|&nbsp;</span>
		<?php echo $html->link('Opdrachten', array('controller' => 'pitches', 'action' => 'index'), array('class'=>'deselected')); ?>
		<span>|&nbsp;</span>
		<?php echo $html->link('Vacatures', array('controller' => 'jobs', 'action' => 'index'), array('class'=>'deselected')); ?>
	</div>
</div>
				<div class="content-wrapper ui-corner-all">
				
				<div class="block-white-top ui-corner-tl ui-corner-tr">
					<div class="clear"></div>
						
							
							<!--               Lijst Updates                                -->
						
						
						<?php
						$i = count($updates['Pitches'])-1;
						$j = count($updates['Designs'])-1;
						$k = count($updates['Comments'])-1;
						
						//echo $i;
						//echo $j;
						//echo $k;
						
						$l = $i + $j + $k +3;
						//echo $l;
						for ($m = 0; $m < $l; $m++) {
							if (isset($updates['Pitches'][$i]['Pitch'])) {
								if (isset($updates['Designs'][$j]['Design'])) {
									if ($updates['Pitches'][$i]['Pitch']['created'] > $updates['Designs'][$j]['Design']['created']) {
										if (isset($updates['Comments'][$k]['Comment'])) {
											if ($updates['Pitches'][$i]['Pitch']['created'] > $updates['Comments'][$k]['Comment']['created']) {
												$pitch = array_pop($updates['Pitches']);
												$i = $i -1;
												echo $this->element('new_pitch',array('pitch'=>$pitch));
											} elseif ($updates['Designs'][$j]['Design']['created'] > $updates['Comments'][$k]['Comment']['created']) {
												$design = array_pop($updates['Designs']);
												$j = $j -1;
												echo $this->element('design_update', array('design' => $design));
											} else {
												$comment = array_pop($updates['Comments']);
												$k = $k -1;
												echo $this->element('comment_update', array('comment' => $comment));
											}
										} else {
											$pitch = array_pop($updates['Pitches']);
											$i = $i -1;
											echo $this->element('new_pitch',array('pitch'=>$pitch));
										}
									} elseif (isset($updates['Comments'][$k]['Comment'])) {
										if ($updates['Designs'][$j]['Design']['created'] > $updates['Comments'][$k]['Comment']['created']) {
											$design = array_pop($updates['Designs']);
											$j = $j -1;
											echo $this->element('design_update', array('design' => $design));
										} else {
											$comment = array_pop($updates['Comments']);
											$k = $k -1;
											echo $this->element('comment_update', array('comment' => $comment));
										}
									} else {
										$design = array_pop($updates['Designs']);
										$j = $j -1;
										echo $this->element('design_update', array('design' => $design));
									}
								} elseif (isset($updates['Comments'][$k]['Comment'])) {
									if ($updates['Pitches'][$i]['Pitch']['created'] > $updates['Comments'][$k]['Comment']['created']) {
										$pitch = array_pop($updates['Pitches']);
										$i = $i -1;
										echo $this->element('new_pitch',array('pitch'=>$pitch));
									} else {
										$comment = array_pop($updates['Comments']);
										$k = $k -1;
										echo $this->element('comment_update', array('comment' => $comment));
									}
								} else {
									$pitch = array_pop($updates['Pitches']);
									$i = $i -1;
									echo $this->element('new_pitch',array('pitch'=>$pitch));
								}
							} elseif (isset($updates['Designs'][$j]['Design'])) {
								if (isset($updates['Comments'][$k]['Comment'])) {
									if ($updates['Designs'][$j]['Design']['created'] > $updates['Comments'][$k]['Comment']['created']) {
										$design = array_pop($updates['Designs']);
										$j = $j -1;
										echo $this->element('design_update', array('design' => $design));
									} else {
										$comment = array_pop($updates['Comments']);
										$k = $k -1;
										echo $this->element('comment_update', array('comment' => $comment));
									}
								} else {
									$design = array_pop($updates['Designs']);
									$j = $j -1;
									echo $this->element('design_update', array('design' => $design));
								}
							} elseif (isset($updates['Comments'][$k]['Comment'])) {
								$comment = array_pop($updates['Comments']);
								$k = $k -1;
								echo $this->element('comment_update', array('comment' => $comment));
							} else {
								echo 'einde';
							}
							if ($i < 0) { $i = 0; }
							if ($j < 0) { $j = 0; }
							if ($k < 0) { $k = 0; }
						}
									
						
						?>
						
						<!-- <pre><?php print_r($updates); ?></pre> -->
							
							
					</div>
					<div class="white-bottom ui-corner-br ui-corner-bl">
					</div>
				

								
